<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
	</view>
</template>

<script>
	import StompClient from '@/libs/stomp-over-uni-socket.js';
	export default {
		data() {
			return {
				title: 'Hello'
			}
		},
		onLoad() {
			// #ifdef H5
			let ws_url = 'ws://localhost:5173'
			// #endif
			// #ifdef APP-PLUS
			let ws_url = 'ws://192.168.50.10:10000'
			// #endif
			
			let token =
				"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Im15LWtpZCJ9.eyJzdWIiOiIxMzgwMDEzODAwMCIsInVzZWRfY2xpZW50IjoiU2NyaXB0d3JpdGVySDUiLCJ1c2VyX2lkIjoyMzE3ODE0MjkyNDgsInVzZXJfbmlja25hbWUiOiLmiYvmnLrnlKjmiLciLCJ1c2VyX2F2YXRhcl91cmwiOm51bGwsInVzZXJfcmVhbF9uYW1lIjpudWxsLCJ1c2VyX2dlbmRlciI6bnVsbCwiYm91bmRfb3JnX2lkIjpudWxsLCJib3VuZF9vcmdfbmFtZSI6bnVsbCwiYm91bmRfb3JnX3VuaWZpZWRfc29jaWFsX2NyZWRpdF9jb2RlIjpudWxsLCJhdWQiOlsiYXJjaGl2ZXMiLCJhdXRoMiIsImNyZWF0aW9ucyIsInRyYWRlcyJdLCJleHAiOjE2OTA3MDYyNjksInVzZXJfbmFtZSI6IjEzODAwMTM4MDAwIiwianRpIjoiZUVKejRScWhyV0ZNbnNqdWtPZmJtMEpnOFFRIiwiY2xpZW50X2lkIjoiU2NyaXB0d3JpdGVySDUiLCJzY29wZSI6WyJyZWFkIiwid3JpdGUiXX0.M8CTyn8hssuQlhLs8bnMmbti-n7Ik3O1RZlDnNioyAXMTRZqsMBWQ4bd-BEwSlxwQpsDlRVfLzHeQSa0yT179GV9oSBL6WYT51crmL-nsznaYEaemKcbPS3mQS_-WUslbObNPC509PB4ynQcLTDLrI3N9ZJyqUKh7fRW1Nnffr5kIEwzvV0P4z1mxl20h1Jz4GFYYFNVDTcMKOgMxTrXj-WJ7KT4UfDbb_NjR7qP5fcjvDIqkYQAvJfaEitT7zd_oWNR0elYmR48FQgdMW3fDfstLMTYhIhknHjd9p-RY9dQwsfrVwhEw9taFcppFm4_qohAGeXAfSjDmKE-f8M4qA";
			StompClient.init(ws_url + '/dungeons/ws', {
				Authorization: 'Bearer ' + token
			}).then(client => {
				client.subscribe('/dungeon/4522345234525', function(message) {
					console.log('Received subscribed topic message:', JSON.stringify(message));
				});

				StompClient.sendStompMessage("/dungeon/4522345234525", {}, JSON.stringify({
					type: "Operate",
					content: {
						text: "test message123"
					}
				}));
			});
		},
		methods: {

		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>